


        var scrollDown = false;
        var topUpadate = null;
        var menuColor = null;
        var sideMenuActive = 0;
        var facArwWatching = null;
        //禁止滚动
        function onMouseScroll(e) {
                if(window.innerWidth >= 1024 && !$('.mobileDevice').length){
                    e.preventDefault();
                    if(prevent) return false;
                    var wheel = e.originalEvent.wheelDelta || -e.originalEvent.detail;
                    var delta = Math.max(-1, Math.min(1, wheel) );
                    var secLength = $('section').length;
                    if(delta < 0){//向下滚动
                        scrollDown = true;
                        if(secPresnt == secLength - 1) return false;
                        secPresnt++;
                    }else{//向上滚动
                        scrollDown = false;
                        if(secPresnt == 0) return false;
                        secPresnt--;
                    }
                    setScroll();
                }
        }
        var secPresnt  = 0;
        function setScroll(val){
            sideMenuActive = $('section:eq(' + secPresnt + ')')[0].menuInd;
            $('main .sideMenu .op').removeClass('active');
            $('main .sideMenu .op:eq(' + sideMenuActive + ')').addClass('active');
            if(sideMenuActive == 1){
                var innerH = $('main .sideMenu .sonMenu .inner')[0].offsetHeight;
                $('main .sideMenu .sonMenu').height(innerH);
                $('main .sideMenu .sonMenu li').removeClass('active');
                $('main .sideMenu .sonMenu li:eq(' + ($('section:eq(' + secPresnt + ')')[0].ind) + ')').addClass('active');
            }else{
                $('main .sideMenu .sonMenu li').removeClass('active');
            }

            if(!sideMenuActive){
                $('main .sideMenu .sonMenu').height(0);
            }

            if($('section:eq(' + secPresnt + ')')[0].className.indexOf('cl') >= 0){
                $('.screenLines').addClass('cl');
                $('footer').addClass('cl');
            }else{
                $('.screenLines').removeClass('cl');
                $('footer').removeClass('cl');
            }

            if($('section:eq(' + secPresnt + ')')[0].className.indexOf('cb') >= 0){
                $('header .top .menuBtn').addClass('cb');
            }else{
                $('header .top .menuBtn').removeClass('cb');
            }

            if($('section:eq(' + secPresnt + ')')[0].className.indexOf('cs') >= 0){
                $('main .sideMenu').addClass('cs');
            }else{
                $('main .sideMenu').removeClass('cs');
            }
            prevent = true;
            var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
            var winH = window.innerHeight;
            var final = winH * secPresnt;
            var scrlDown = final > scrollTop?true:false;
            var duration = val == undefined?10:20;
            if(scrlDown){
                var max = Math.ceil((final - scrollTop) / 15);
            }else{
                var max = Math.ceil((scrollTop - final) / 15);
            }
            topUpadate = setInterval(function(){
                var intTop = document.documentElement.scrollTop || document.body.scrollTop;
                var val;
                if(Math.abs(intTop - final) <= 300 && val == undefined){
                    if(scrlDown){
                        val = Math.ceil((final - intTop) / 7);
                    }else{
                        val = Math.ceil((intTop - final) / 7);
                    }
                }else if(val == 'extra'){
                    if(scrlDown){
                        val = max - Math.ceil((final - intTop) / 25) + 2;
                    }else{
                        val = max - Math.ceil((intTop - final) / 25) + 2;
                    }
                }else{
                    if(scrlDown){
                        val = max - Math.ceil((final - intTop) / 15) + 2;
                    }else{
                        val = max - Math.ceil((intTop - final) / 15) + 2;
                    }
                    
                }
                if(scrlDown){
                    intTop += val;
                    if(intTop >= final){
                        intTop = final;
                    }
                }else{
                    intTop -= val;
                    if(intTop <= final){
                        intTop = final;
                    }
                }
                document.documentElement.scrollTop = document.body.scrollTop = intTop;
                if(intTop == final){
                    clearInterval(topUpadate);
                    prevent = false;
                }
            },duration)
        }
        var mouseOnScrl = false;
        function release(){
            if(window.innerWidth < 1024 || $('.mobileDevice').length) return false;
            if(mouseOnScrl && !prevent){
                for(var s = 0;s < $('section').length;s++){
                    var secTop = $('section')[s].getBoundingClientRect().top;
                    if(secTop >=  - window.innerHeight / 2 && secTop <= window.innerHeight / 2){
                        secPresnt = s;
                        prevent = true
                        setScroll('extra');
                        break;
                    }
                }
            }
        }
        $(document).ready(function(){
                beginningAtTop();
                $('main .sideMenu .op:first-child').addClass('active');
                $('main .proRcmd .content .choose .op:first-child').addClass('active');
                $('main .proRcmd .content .opacitySwiper img:first-child').addClass('active');
                $('main .proRcmd .content .descFlip .item:first-child').addClass('active');
                $('main .btns .prev').addClass('unclickable');
                $('main .facEnvrmt .parts .box:first-child').addClass('active');
                $('main .facEnvrmt .imgSwitch .pic:first-child').addClass('active');
                $('main .news .txt .newsSwiper .item:first-child').addClass('active');
                $('main .news .imgSwitch img:first-child').addClass('active');
                for(var r = 0;r < $('main .proRcmd').length;r++){
                    $('main .proRcmd')[r].ind = r;
                }
                var menuInd = 0;
                for(var s = 0;s < $('section').length;s++){
                    $('section')[s].menuInd = menuInd;
                    if($('section')[s].className.indexOf('proRcmd') < 0 || 
                    ($('section')[s].className.indexOf('proRcmd') >= 0 && $('section:eq(' + (s + 1) + ')')[0].className.indexOf('proRcmd') < 0)){
                        menuInd++;
                    }
                }
                var secInd = 0;
                for(var s = 0;s < $('main .sideMenu .op').length;s++){
                    if($('main .sideMenu .op')[s].children.length > 1){
                        for(var c = 0;c < $('main .sideMenu .op:eq(' + s + ')').find('.inner')[0].children.length;c++){
                            $('main .sideMenu .op:eq(' + s + ')').find('.inner')[0].children[c].secInd = secInd;
                            secInd++;
                        }
                        
                    }else{
                        $('main .sideMenu .op')[s].secInd = secInd;
                        secInd++;
                    }
                    
                }
                $('main .sideMenu .op').click(function(){
                    var thisSecInd = $(this)[0].secInd == undefined?1:$(this)[0].secInd;
                    secPresnt = thisSecInd;
                    setScroll();
                })
                $('main .sideMenu .inner li').click(function(e){
                    var thisSecInd = $(this)[0].secInd;
                    secPresnt = thisSecInd;
                    setScroll();
                    e = e || window.event;
                    e.cancelBubble = true;
                    e.stopPropagation();
                    if(e.preventDefault){ // w3c
                        e.preventDefault();
                    } else { // ie
                        e.returnValue = false;
                    }
                })

                $('main .arrow.rotate').click(function(){
                    secPresnt++;
                    setScroll();
                })
                $('body').mouseenter(function(){
                    mouseOnScrl = false;
                })
                $('body').mouseleave(function(){
                    mouseOnScrl = true;
                })
                function switchImg(prntInd,ind){
                    console.log(prntInd,ind);
                    if(!ind){
                        $('main .proRcmd:eq(' + prntInd + ') .content .purpose').removeClass('hidden');
                    }else{
                        $('main .proRcmd:eq(' + prntInd + ') .content .purpose').addClass('hidden');
                    }
                    $('main .proRcmd:eq(' + prntInd + ') .content .choose .op').removeClass('active');
                    $('main .proRcmd:eq(' + prntInd + ') .content .choose .op:eq(' + ind + ')').addClass('active');
                    $('main .proRcmd:eq(' + prntInd + ') .opacitySwiper img').removeClass('active');
                    $('main .proRcmd:eq(' + prntInd + ') .opacitySwiper img:eq(' + ind + ')').addClass('active');
                    $('main .proRcmd .content .descFlip .item').removeClass('active');
                }
                $('main .proRcmd .content .choose .op').click(function(){
                    var dadInd = $(this).parents('.proRcmd')[0].ind;
                    var length = $('main .proRcmd:eq(' + dadInd + ') .content .choose .op').length;
                    var ind = $(this).index();
                    if($(this)[0].className.indexOf('avtive') >= 0) return false;
                    $('main .proRcmd .content .btns p').removeClass('unclickable');
                    if(!ind){
                        $('main .proRcmd .content .btns .prev').addClass('unclickable');
                    }else if(ind == length -1){
                        $('main .proRcmd .content .btns .next').addClass('unclickable');
                    }
                    switchImg(dadInd,ind);
                })
                $('main .proRcmd .content .btns p').click(function(){
                    if($(this)[0].className.indexOf('unclickable') >= 0) return false;
                    var dadInd = $(this).parents('.proRcmd')[0].ind;
                    var ind;
                    var length = $('main .proRcmd:eq(' + dadInd + ') .content .choose .op').length;
                    for(var b = 0;b < length;b++){
                       if($('main .proRcmd:eq(' + dadInd + ') .content .choose .op')[b].className.indexOf('active') >= 0){
                            ind = b;
                            break;
                       } 
                    }
                    $('main .proRcmd .content .btns p').removeClass('unclickable');
                    if($(this)[0].className.indexOf('prev') >= 0){
                            ind--;
                            if(!ind){
                                $(this).addClass('unclickable');
                            }
                    }else{
                            ind++;
                            if(ind == length - 1){
                                $(this).addClass('unclickable');
                            }
                    }
                    switchImg(dadInd,ind);
                })
                for(var b = 0;b < $('main .facEnvrmt .parts .box').length;b++){
                    $('main .facEnvrmt .parts .box')[b].ind = b;
                }
                $('main .facEnvrmt .parts .box .sTtl p').click(function(){
                    $('main .facEnvrmt .parts .box').removeClass('active');
                    $(this).parents('.box').addClass('active');
                    var ind = $(this).parents('.box')[0].ind;
                    $('main .facEnvrmt .imgSwitch .pic').removeClass('active');
                    $('main .facEnvrmt .imgSwitch .pic:eq(' + ind + ')').addClass('active');
                    $('main .facEnvrmt .imgSwitch')[0].style.transform = 'translateX(' + (-ind * 100) + '%)';
                })
                facArwWatching = setInterval(function(){
                    var left;
                    var actv = $('main .facEnvrmt .parts .box.active')[0].ind;
                    if(window.innerWidth >= 768){
                        $("main .facEnvrmt .arrow")[0].style.left = (100 / 6 * (actv + 1)).toFixed(5) + '%';
                    }else{
                        $("main .facEnvrmt .arrow")[0].style.left = (25 * actv).toFixed(5) + '%';
                    }
                    if(parseFloat($("main .facEnvrmt .arrow")[0].style.left) != left){
                        $("main .facEnvrmt .arrow")[0].style.left = left + '%';
                    }
                },10)
                var max = 0;
                for(var n = 0;n < $('main .news .txt .newsSwiper .item').length;n++){
                    var h = $('main .news .txt .newsSwiper .item')[n].offsetHeight;
                    if(h > $('main .news .txt .newsSwiper .item')[max].offsetHeight){
                        max = n;
                    }
                }
                $('main .news .txt .newsSwiper .item:eq(' + max + ')').addClass('max');
                function switchNews(ind){
                    $('main .news .txt .newsSwiper .item').removeClass('active');
                    $('main .news .txt .newsSwiper .item:eq(' + ind + ')').addClass('active');
                    $('main .news .imgSwitch img').removeClass('active');
                    $('main .news .imgSwitch img:eq(' + ind + ')').addClass('active');
                }
                $('main .news .btns p').click(function(){
                    console.log('c')
                    if($(this)[0].className.indexOf('unclickable') >= 0) return false;
                    var ind;
                    var length = $('main .news .txt .newsSwiper .item').length;
                    for(var n = 0;n < length;n++){
                       if($('main .news .txt .newsSwiper .item')[n].className.indexOf('active') >= 0){
                            ind = n;
                            break;
                       } 
                    }
                    $('main .news .btns p').removeClass('unclickable');
                    if($(this)[0].className.indexOf('prev') >= 0){
                            ind--;
                            if(!ind){
                                $(this).addClass('unclickable');
                            }
                    }else{
                            ind++;
                            if(ind == length - 1){
                                $(this).addClass('unclickable');
                            }
                    }
                    switchNews(ind);
                })
                
                
                menuColor = setInterval(function(){
                    if(!$('.mobileDevice').length)return false;
                    for(var s = 0;s < $('section').length;s++){
                        var winH = window.innerHeight;
                        var eleTop = $('section')[s].getBoundingClientRect().top;
                        if(eleTop > -winH / 2 && eleTop < winH / 2){
                            if($('section')[s].className.indexOf('cb') >= 0 && $('header .top .menuBtn')[0].className.indexOf('cb') < 0){
                                $('header .top .menuBtn').addClass('cb');
                            }else if($('section')[s].className.indexOf('cb') < 0 && $('header .top .menuBtn')[0].className.indexOf('cb') >= 0){
                                $('header .top .menuBtn').removeClass('cb');
                            }
                            if($('section')[s].className.indexOf('cl') >= 0 && $('.screenLines')[0].className.indexOf('cl') < 0){
                                $('.screenLines').addClass('cl');
                            }else if($('section')[s].className.indexOf('cl') < 0 && $('.screenLines')[0].className.indexOf('cl') >= 0){
                                $('.screenLines').removeClass('cl');
                            }
                            break;
                        }
                    }
                },10)

                
        })
        $(document).on('mouseup',release);
        $(document).on('mousewheel DOMMouseScroll', onMouseScroll);